package org.dtrd.modules.record.entity.bean;

import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.dtrd.common.util.DateUtils;
import org.dtrd.config.system.Constant;
import org.dtrd.modules.record.entity.po.DtrdEntRdSigninBloodPressure;

import java.util.Date;

/**
 * 血压Bean
 *
 * @author lizhongcheng
 * @since 2015-12-10
 */
@Data
@NoArgsConstructor
@ApiModel("血压记录数据对象")
public class BloodBean implements java.io.Serializable {
    private static final long serialVersionUID = 6251136899952437573L;
    /**
     * 定义本类的私有变量
     */
    @ApiModelProperty("记录id")
    private Integer id;

    @ApiModelProperty("高压")
    private Integer high;

    @ApiModelProperty("低压")
    private Integer low;

    @ApiModelProperty("记录时间")
    private String time;
    @ApiModelProperty("记录时间")
    private String recordTime;

    @ApiModelProperty("备注")
    private String remark;

    @ApiModelProperty("患者id")
    private Integer patientId;

    @ApiModelProperty("心率")
    private Integer heart;

    @ApiModelProperty(value = "记录类型", notes = "1 -晨起 2-睡前 3-随机 ")
    private Integer recordType;

    @ApiModelProperty("照片以 竖线 | 拼接")
    private String recordPhoto;

    public String getTime() {
        return time==null?recordTime:time;
    }

    public BloodBean(Integer patientId, Date time, Integer high, Integer low, Integer pluse,
                     Constant.BloodPressureRecordType type) {
        this.patientId = patientId;
        this.high = high;
        this.low = low;
        this.time = DateUtils.formatDate(time, DateUtils.datetimeFormat.get().toPattern());
        this.heart = pluse;
        this.recordType = type.getType();
    }

    public BloodBean parseFromPo(DtrdEntRdSigninBloodPressure po) {
        id = po.getDataId();
        high = po.getBloodPressureHighPressure();
        low = po.getBloodPressureLowVoltage();
        try {
            time = DateUtils.formatDate(po.getRecordDate(), DateUtils.date_sdf.get().toPattern());
        } catch (Exception e) {
            e.printStackTrace();
        }
        remark = po.getBloodPressureRemark();
        patientId = po.getPatientId();
        heart = po.getBloodPressureHeartRate();
        recordType = po.getBloodPressureType();
        recordPhoto = po.getRecordPhoto();
        return this;
    }
}